#include<vector>
using namespace std;

int minOperations(vector<int>& nums, int x) {
    int sum = 0;
    for (auto e : nums) sum += e;
    if (sum < x) return -1;
    int target = sum - x;
    int len = 0;
    int add = 0;
    for (int left = 0, right = 0; right < nums.size(); right++)
    {
        add += nums[right];
        while (add > target)
        {
            add -= nums[left];
            left++;
        }
        if (add == target)
            len = max(len, right - left + 1);
    }
    return len == 0 ? -1 : nums.size() - len;
}

int main()
{
    vector<int> v{ 8828,9581,49,9818,9974,9869,9991,10000,10000,10000,9999,9993,9904,8819,1231,6309 };
    minOperations(v, 134365);

	return 0;
}